import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { TableBookConf } from "../../common/table/TableBookConf";

/** 
 * 武将图鉴属性数据
 */
@ecs.register('RoleModelBook')
export class RoleModelBookComp extends ecs.Comp {
    /** 提供MVVM组件使用的数据 */
    vm: any = {};

    /** 合成物编号 */
    get id(): number {
        return this.table.id;
    }
    set id(value: number) {
        if (this.table == null) this.table = new TableBookConf();
        this.table.init(value);
    }
    table: TableBookConf = null!;

    /** 已经领取过星星的次数 */
    public collectEmblemStar: number = 0;

    /** 当前可以领取的星星属性 */
    private _star: number = 0;
    public get star() : number {
        return this._star;
    }
    public set star(v : number) {
        this._star = v;
        this.vm["star"] = v;
    }

    /** 是否可以领取星星 */
    private _canReceiveStar: number = 0;
    public get canReceiveStar() : number {
        return this._canReceiveStar;
    }
    public set canReceiveStar(v : number) {
        this._canReceiveStar = v;
        this.vm["canReceiveStar"] = v;
    }

    constructor() {
        super();
    }

    reset() {
        this._star = 0;
        this._canReceiveStar = 0;
        this.collectEmblemStar = 0;
        for (var key in this.vm) {
            delete this.vm[key];
        }
    }
}
